class Child {
    constructor() {
        this.parents = [];
    }
    emit(something) {
        this.parents.forEach((item)=> {
            item(something)
        })
    }
    collect(item){
        this.parents.push(item)
    }
}

class Parent {
    constructor(name){
        this.name = name;
        this.dosomething=(info)=> {
            console.log(this.name+'收到通知:',info)
        }
    }
}

const child = new Child();
const father = new Parent('父亲');
const mother = new Parent('母亲');
child.collect(father.dosomething);
child.collect(mother.dosomething);
child.emit("我要吃奶");






